<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Document extends CI_Model {
    public function __construct() {
    	parent::__construct();
    }
	
    public function getPages($options = array()) {
    	$options = _default(array('sortDirection' => 'asc'), $options);
    	$queryFields = array('pag_id', 'pag_description', 'pag_name', 'pag_title');

    	foreach ($queryFields as $field) {
    		if (isset($options[$field]))
    			$this->db->where($field, $options[$field]);
    	}
    	
    	if (isset($options['limit']) && isset($options['offset']))
    		$this->db->limit($options['limit]'], $options['offset']);
    	else if (isset($options['limit']))
    		$this->db->limit($options['limit]']);
    	
    	if (isset($options['sortBy']))
    		$this->db->order_by($options['sortBy'], $options['sortDirection']);
    	$query = $this->db->get('acs_pages');
    	if ($query->num_rows() == 0)
    		return FALSE;
    	if (isset($options['pag_name']))
    		return $query->row(0);
    	else
    		return $query->result_array();
    }
    
    public function updatePage($options = array()) {
    }
    
    public function insertPage($options = array()) {
    }
    
	public function deletePage($options = array()) {
    }
}
